package cn.wolfcode.p2p.base.listener;

import cn.wolfcode.p2p.base.util.MyRequestContextHolder;

import javax.servlet.ServletRequestEvent;
import javax.servlet.ServletRequestListener;
import javax.servlet.http.HttpServletRequest;

public class MyRequestListener implements ServletRequestListener {

    @Override
    public void requestDestroyed(ServletRequestEvent sre) {
        //请求的必经之路 监听request的创建时间
        //把request对象绑定到当前线程中
        HttpServletRequest servletRequest = (HttpServletRequest)sre.getServletRequest();
        MyRequestContextHolder.setRequestMethod(servletRequest);
    }

    @Override
    public void requestInitialized(ServletRequestEvent sre) {

    }
}
